All right, so today I'm going to make things happen with our part using a script.
So I'm going to change the properties of this part using a script.
That'll be pretty cool.
I'm using my first game from the last video because it's convenient.
You could use a fresh world, but go ahead and add a part and give it a unique name.
I just called it my part.
Now I have this variable script under here from the last video.
I'm going to disable it because we don't need it.
There we go.
I'm going to go to the part, hit the plus, add a script KU Let's rename the script.
I'll call it Change It.
I used a capital C and a capital I get some camel case in there.
That's what they call that.
I can get rid of this.
And before I start scripting, I'm going to take a quick look at the world.
Click on this part.
I'm going to look at some of the properties I want to change, basically brick color.
I want to change the color, right?
You could do that automatically, but you can also do with a script and hit control Z to change it back.
I'm going to go down to transparency.
That's another easy property to change.
So transparency of zero means the part is opaque.
You can't see through it 100%.
Transparent is actually a one.
So the scale is from 0 to 1.
You can't see.
You can't see it.
You can see right through it.
You see the outline when you select it, but that's about it.
Now, if you make it to, it's not going to be any more transparent.
The scale is 0 to 1.
All right, let's make it 0.8, which is 80%.
Right.
80% of one is 0.8.
You can kind of see it.
That's like a little outline there.
That's pretty cool.
Let's go back and change that.
Go to my part, change that transparency back to zero.
And let's do that with a script.
All right.
Change it.
How do we get a variable?
For our part, we need to store my part in a variable.
Once you get that, you're well on your way.
Well, we know we have a scope modifier called local, and then we need a variable.
We can call whatever we want.
I think I'll just call it part.
Now to get that part, we have the special word called script.
Script is cool.
It means this script.
It's the same in every script.
If you just say script, it means the script that you are actually typing in or running at the time.
There's a property on script and actually on all game objects and you access a property with a dot called
parent.
All right.
So if we mean this script, we mean change it.
The parent is my part.
You can kind of see that relationship, right?
A parent child relationship.
That's the parent my part.
Also, if you click change it and you look at parent, it says my part.
So it actually tells you these are the properties.
Cool.
Now we have essentially right here a reference to my part.
We're going to stick it in that variable and then we're going to see if we can print out the name.
My part, because that's his name.
So print the parts name is equal to and I'll just say part dot name.
Name is also a property of part if you go to my part.
Name my part.
It should print out my part.
That's a go to view output.
And then we'll hit this little triangle thing to play it.
Oh, look at that.
The part's name is my part.
I'll make it a little bigger.
There we go.
We got it.
We got the name of that part.
Cool.
Now, what can we do with it?
Let's change the transparency.
Let's make it a little bit invisible.
But we want to see it when we go in the world.
We want to see it turn invisible.
I'm going to go well, partially invisible.
We still want to be able to see it.
I'm going to go and do this weight function.
It's a Roblox function.
It gives you a little bit of a of a definition of what it does.
It's going to yield the thread, actually.
It's going to yield this script so that it doesn't run for this many seconds.
We'll say 6 seconds.
That'll give us enough time to get in the world and find the part.
All right.
So we're going to wait.
Everything else is running in the game.
It's just yielding this script.
It's stopping, it's waiting.
And then after 6 seconds, we're going to say part dot transparency.
Look at that.
We've got IntelliSense.
That DOT is the property operator.
We can access the properties.
When we hit a T, we get this IntelliSense that says, hey, what do you mean transparency, maybe?
Oh, yeah, transparency.
And now we could say, I don't know, 0.5.
Let's try that.
Go ahead and play it.
There's our part.
Boom.
With that 50% transparency, you can kind of see through it.
Nice.
Let's make it become less and less transparent over time.
Now, we can't really blend it.
We don't know loops and stuff like that.
We don't know a lot of cool gaming techniques, but we could do this manually.
We could say, Wait one second, and then we'll say part transparency and maybe let's make it like point
seven and then wait another second part dot transparency equals point nine.
You might just see an outline of it very barely and you can make it one.
So it's completely invisible.
But I think what I'm going to do after another second is just make it opaque again.
So do a T transparency.
Opaque is zero.
Can't see through it.
All right, let's try it.
There's our part.
Now it's turning very oh, you barely see it at point nine.
That's pretty cool.
And then went back to opaque.
Sweet.
What else can we do?
Anything in this list?
And it's going to take a few videos to get through some of the cooler stuff, but I'm going to try and
go quickly so I don't bore you too much.
Here's brick color, brick color and color.
They work together, but brick color gives you names of colors like blue, right?
Or green or lime green.
This is a really blue.
This is a really this is actually called really blue.
Right.
All right.
Let's let's do that with code.
Let's go ahead and make that control, Z.
There you go.
Medium stone, gray control.
Z undoes things.
Let's go to change it after our little transparency experiment.
Let's wait another second.
Let's change the brick color.
So if we say part B, ooh, look at that brick color.
Cool.
I'm going to click on it now.
Brick color doesn't take a number.
Brick color takes a brick color.
Just one of those things you got to know.
So we got a little bee there good that our IntelliSense gave us our bird color so we don't even have
to know that much.
Let's do a dot and I will make that red.
So we have some pre defined functions for colors and I'm going to show you how to do another color because
if we do part dot brick color, you will notice brick color only has oops, I need a dot a few of these
predefined colors.
Not everything in the palette.
You do have a palette object, but if you want like lime green, if we click on part, open that thing
up.
You see that lime green right there that is not part of the dot.
And then with a function we need to make that special.
So we will do something called new, right?
It will instantiate a new color object and then we do the speech quotes.
Now you can get everything in the palette lime green cool as wait another second, we'll do part and
we have this other cool function in brick color.
I know we haven't done functions yet.
Just trust me on it.
We do this dot random.
We'll get a random color so it'll be different every time we run the game.
Well, by chance it could be the same two times in a row, but typically it's the different area.
We're going to watch it turn invisible.
Yeah.
There you go.
Cool.
Opaque red, lime green.
And then there's our random color.
All right, so the next video, let's start changing sizes and possessions.
That that'll be pretty cool, too.